require(["common", "hash_routie", "coAjax", "queryString", "jQuery", "browser", "href", "eventManager", "/js/common/goodsCart.js"], function(jSouper, hash_routie, coAjax, QueryString, $, browser, href, eventManager, goodsCart) {
	/*
	 * HASH路由
	 */
	hash_routie({
		html_url: "./pages/mb/default/",
		js_url: "./js/mobile/default/",
		hash_prefix: "default/:page",
		default_hash: "main",
		teleporter: "main"
	});

	//获取指定页的商品
	coAjax.get(appConfig.goods.list, {
		bus_id: busInfo._id,
		num: 10,
		page: 0
	}, function(result) {
		var goods_list = result.result;
		App.set("goods_list", goods_list);
	}, function() {
		console.log(arguments);
	});

	App.set('$Event.href', function() {
		if (App.get('$Cache.search_text')) {
			href.jump("#default/searchset?q=" + App.get('$Cache.search_text'))
		} else {
			alert('error', '请输入搜索关键词');
		}
	})

	function _get_cart_success(result) {
		var cart_detail = result.result;
		App.set("user.cart_detail", cart_detail);
		href.jump("/mobile.main.html#default/cart");
	};

	App.set("$Event.goods_list.add_to_cart", function(e, vm) {
		var cart_item = {
			goods_id: vm.get("_id"),
			num: 1
		};
		goodsCart.add_to_cart(vm.get("_id"), 1, _get_cart_success)
	});
});